package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdSpeciesMapper;
import com.diankangwo.factory.entity.TdSpecies;
import com.diankangwo.factory.service.TdSpeciesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/** 保存三级分类
 * Created by wuye on 2017/9/11.
 */
@Service("TdSpeciesService")
public class TdSpeciesServiceImpl implements TdSpeciesService {

    @Autowired
    private TdSpeciesMapper mapper;

    @Override
    @Transactional
    public void save(TdSpecies tdSpecies) {
        tdSpecies.setClasstime(new Date());
        tdSpecies.setIsdelete(0);
        tdSpecies.setClassorder(0);
        mapper.insert(tdSpecies);
    }

    @Override
    public List<TdSpecies> queryAll() {
        return mapper.queryAll();
    }

    @Override
    public List<TdSpecies> queryByClaId(int claId) {
        return mapper.queryByClaId(claId);
    }

    @Override
    public TdSpecies selectByPrimaryKey(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void deleteBatch(int claId) {
        mapper.deleteBatch(claId);
    }

    @Override
    @Transactional
    public void delete(int id) {
        mapper.deleteByPrimaryKey(id);
    }
}
